﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.woodsoft.core;
using com.woodsoft.core.Files;
using EQ1.Elements;
using EQ1.Objects;

namespace EQ1.Templates {
  public class GaugeDrawTemplate : UIClass , IUIElement<GaugeDrawTemplate> {
    public GaugeDrawTemplate ( UIDocument doc , string name )
      : base( doc , name ) {
    }
    public GaugeDrawTemplate ( UIDocument doc )
      : this( doc , "GaugeDrawTemplate" ) {
    }

    #region IUIElement<GaugeDrawTemplate> Members

    public void Validate ( GaugeDrawTemplate val , string name ) {
      UIClass par = ( UIClass ) this.ParentNode;

      if( val.LocalName != name ) {
        GaugeDrawTemplate el = new GaugeDrawTemplate( ( UIDocument ) val.OwnerDocument , name );
        el.Copy( val );
        val = el;
      }

      if( par.GetElement( name ) != null )
        par.RemoveElement( name );

      par.AppendChild( val );
    }
    public void Copy ( GaugeDrawTemplate val ) {
      base.Copy( val );

      if( !string.IsNullOrEmpty( val.Background ) )
        this.Background = val.Background;
      if( !string.IsNullOrEmpty( val.Fill ) )
        this.Fill = val.Fill;
      if( !string.IsNullOrEmpty( val.Lines ) )
        this.Lines = val.Lines;
      if( !string.IsNullOrEmpty( val.LinesFill ) )
        this.LinesFill = val.LinesFill;
      if( !string.IsNullOrEmpty( val.EndCapRight ) )
        this.EndCapRight = val.EndCapRight;
      if( !string.IsNullOrEmpty( val.EndCapLeft ) )
        this.EndCapLeft = val.EndCapLeft;
    }

    #endregion
    
    public string Background {
      get {
        return this.GetElement( "Background" ).InnerText;
      }
      set {
        this.Validate( "Background" , value );
      }
    }
    public string Fill {
      get {
        return this.GetElement( "Fill" ).InnerText;
      }
      set {
        this.Validate( "Fill" , value );
      }
    }
    public string Lines {
      get {
        return this.GetElement( "Lines" ).InnerText;
      }
      set {
        this.Validate( "Lines" , value );
      }
    }
    public string LinesFill {
      get {
        return this.GetElement( "LinesFill" ).InnerText;
      }
      set {
        this.Validate( "LinesFill" , value );
      }
    }
    public string EndCapRight {
      get {
        return this.GetElement( "EndCapRight" ).InnerText;
      }
      set {
        this.Validate( "EndCapRight" , value );
      }
    }
    public string EndCapLeft {
      get {
        return this.GetElement( "EndCapLeft" ).InnerText;
      }
      set {
        this.Validate( "EndCapLeft" , value );
      }
    }

  }
}
